import React from 'react'
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles'
import TextField from '@material-ui/core/TextField'


const styles = theme => ({

})
const PROPS_BLACKLIST = [
    'parameters',
    'onChange'
];

const cleanProps = (props) => {
    PROPS_BLACKLIST.forEach(field => delete props[field]);
    return props;
};

class NormalTextField extends React.Component  {

    handleTextChange = (event) => {
        const value = event.target.value
        this.props.onChange(value, ...this.props.parameters)
    }

    render(){
        const { ...props } = this.props;
        cleanProps(props);

        return (
            <TextField {...props} onChange={this.handleTextChange}></TextField>
        )
    }
}
NormalTextField.propTypes = {
    onChange: PropTypes.func,
    parameters: PropTypes.array
}
export default withStyles(styles)(NormalTextField)